Skip to content

Simplify the source sink interactions#368

Merged
mch2 merged 2 commits into
mch2:scheduler-initialfrom
Bukhtawar:scheduler-initial-sink-source
Apr 17, 2026
Merged

Simplify the source sink interactions#368
mch2 merged 2 commits into
mch2:scheduler-initialfrom
Bukhtawar:scheduler-initial-sink-source

Conversation

@Bukhtawar

@Bukhtawar Bukhtawar commented Apr 17, 2026

Copy link
Copy Markdown

Description

  1. ExchangeSink/ExchangeSource split — The original ExchangeSink mixed write and read concerns in one interface (feed(), close(), readResult(), getRowCount(), getValueAt()). Split into write-only ExchangeSink (feed + close) in the analytics-framework SPI and read-only ExchangeSource (readResult + getRowCount) in the same module. RowProducingSink implements both as the backing store, with getValueAt kept as a concrete method. Producers only see ExchangeSink, the walker only sees ExchangeSource.

  2. DataProducer/DataConsumer interfaces — The original SinkProvidingStageExecution was implemented by all stage types but meant different things on each. ShardFragmentStageExecution (a leaf) used it to expose the sink it writes into. PassThroughStageExecution and LocalStageExecution (middle nodes) used it to provide sinks to children. Introduced DataProducer (outputSink() + outputSource()) and DataConsumer (inputSink(int)). ShardFragmentStageExecution now implements only DataProducer. SinkProvidingStageExecution became a marker combining both for middle stages. The builder resolves sinks via DataConsumer, the walker reads results via DataProducer.

  3. ResponseCodec extraction — The ~170 lines of scanResponseToArrow, inferArrowType, and setVectorValue were embedded in ShardFragmentStageExecution, coupling it to the Object[] wire format. Extracted into RowResponseCodec behind a ResponseCodec functional interface. The codec is injected by ShardFragmentStageScheduler. ShardFragmentStageExecution dropped from ~290 to ~120 lines with zero Arrow type-manipulation imports. Swapping to Arrow IPC transport means writing a new codec — no stage/sink/walker changes.

  4. Two-phase scheduler (ExecutionGraph) — PlanWalker.walk() was monolithic: build graph + start execution in one call. Split into build() → ExecutionGraph → start(graph). ExecutionGraph is an inspectable intermediate representation holding all stage executions in CREATED state with listeners wired. Its explain() method returns a human-readable summary. QueryScheduler now has plan(config) for EXPLAIN (build-only, no dispatch) and execute(config, listener) for normal queries. The legacy walk() calls both for backward compatibility.

Related Issues

Resolves # opensearch-project#21242

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
@mch2
mch2 merged commit e59e62b into mch2:scheduler-initial Apr 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants